@extends('layouts.root')
@section('title' , '客户后台')

@section('styles')
    <link rel="stylesheet" href="{{ asset('layuiadmin/style/login.css') }}">
@endsection


<!-- 主体内容 -->
@section('contents')
    <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display:;">

        <div class="layadmin-user-login-main">
            <div class="layadmin-user-login-box layadmin-user-login-header">
                <h2>方</h2>
                <p>客户管理后台登陆</p>
            </div>
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                    <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                    <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-xs7">
                            <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                            <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input">
                        </div>
                        <div class="layui-col-xs5">
                            <div style="margin-left: 10px;">
                                <img src="{{ captcha_src('flat') }}" onclick="this.src = '/captcha/flat?'+ Math.random()" class="layadmin-user-login-codeimg" id="">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item" style="margin-bottom: 20px;">
                    <input type="checkbox" name="remember" value="1" lay-skin="primary" title="记住密码">
                    @csrf
                    <a href="#" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
                </div>
                <div class="layui-trans layui-form-item layadmin-user-login-other">
                    <a href="reg.html" class="layadmin-user-jump-change layadmin-link">注册帐号</a>
                </div>
            </div>
        </div>

    </div>

@endsection


@section('scripts')
    <script>
        layui.config({
            base: '/layuiadmin/'
        }).extend({
            index: 'lib/index',
        }).use(['index','sample','user'],function(){
            var $ = layui.$
                ,setter = layui.setter
                ,admin = layui.admin
                ,form = layui.form
                ,router = layui.router()
                ,search = router.search;

            form.render();

            //提交
            form.on('submit(LAY-user-login-submit)', function(obj){

                var field = obj.field;
                //请求登入接口
                $.post({
                    url: "{{ route('zbsuser.login.store') }}",
                    data: field,
                    dataType:'json',
                    success:function(res){
                        if (res.code == 0){
                            layer.msg(res.msg,{icon:5,time:1500},function(){
                                $('.layadmin-user-login-codeimg').click();
                            });
                        }else{
                            layer.msg(res.msg , {icon:6,time:1000},function(){
                                location.href = '/zbsuser';
                            });
                        }
                    },
                    error:function(err){
                        var parseJSON = err.responseJSON.errors;
                        var html = '';
                        // 循环打印错误
                        $.each(parseJSON ,function(k , v){
                            html += v +'<br>';
                        });
                        layer.msg(html ,{icon:5},function(){
                            $('.layadmin-user-login-codeimg').click();
                        });
                    }
                });

            });
        });
    </script>
@endsection